import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx/config/resource/assets_images.dart';
import 'package:getx/view_models/main/main_view_model.dart';
import 'package:getx/views/housing/housing_view.dart';
import 'package:getx/views/question/question_view.dart';
import 'package:getx/views/setting/setting_view.dart';

class MainView extends GetView<MainViewModel> {
  const MainView({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
        image: DecorationImage(image: AssetImage(AssetsImages.loginBg), fit: BoxFit.cover),
      ),
      child: Scaffold(
        body: PageView(
          controller: controller.pageController,
          onPageChanged: controller.onPageChange,
          children: [HousingView(), QuestionView(), SettingView()],
        ),
        bottomNavigationBar: Obx(() {
          return BottomNavigationBar(
            elevation: 0,
            backgroundColor: Colors.white24,
            unselectedItemColor: Colors.black87,
            currentIndex: controller.currentIndex.value,
            onTap: controller.bottomNavigationBarTap,
            items: [
              BottomNavigationBarItem(icon: Icon(Icons.house), label: '房屋'),
              BottomNavigationBarItem(icon: Icon(Icons.question_answer), label: '问答'),
              BottomNavigationBarItem(icon: Icon(Icons.settings), label: '设置'),
            ],
          );
        }),
      ),
    );
  }
}
